export PATH=/opt/docker/bin:$PATH

DOCKER_HOST=tcp://127.0.0.1:2377
DOCKER_CERT_PATH=/root/.docker
DOCKER_TLS_VERIFY=1


# 运行和状态
ls /var/lib/docker
ls /var/run/docker
ls /run/containerd

# 镜像下载
https://www.openeuler.org/zh/wiki/install/image
https://dl-cdn.openeuler.openatom.cn/openEuler-20.03-LTS-SP2/docker_img/x86_64/
https://mirrors.aliyun.com/openeuler/openEuler-20.03-LTS-SP2/?spm=a2c6h.25603864.0.0.7a1712a6I29ZtU

# 导入镜像
../bin/docker load -i /opt/docker/openEuler-docker.x86_64.tar.xz


# 查看镜像
../bin/docker images
 
---
REPOSITORY                TAG       IMAGE ID       CREATED       SIZE
openeuler-20.03-lts-sp2   latest    af3cd607ad85   3 years ago   289MB
---

# 创建启动容器
../bin/docker run -it --name cs1 af3cd607ad85 -v /opt/docker:/opt/docker &
../bin/docker run --mount type=bind,source=/opt/package,target=/opt/package -it --name cs1 af3cd607ad85 &

# 端口映射
../bin/docker run -p 3306:3306 -p 5432-5433:5432-5433 --mount type=bind,source=/opt/package,target=/opt/package -it --name cs1 af3cd607ad85 &

*后台运行*
../bin/docker run -d -i --name cs1 af3cd607ad85

# 单独启动/停止容器

../bin/docker ps

*列出所有*
../bin/docker ps -a

../bin/docker start -i xxx_cid

../bin/docker start 80e6cad93da6

*交互式，不会自动退出*
../bin/docker start -i cs1

../bin/docker stop 80e6cad93da6

# 进入

../bin/docker exec -it 80e6cad93da6 /bin/bash


# 保存容器
../bin/docker ps

CONTAINER ID   IMAGE          COMMAND       CREATED          STATUS              PORTS     NAMES
fe403254012d   af3cd607ad85   "/bin/bash"   19 minutes ago   Up About a minute             cs1

../bin/docker commit fe403254012d openeuler-20.03-lts-sp2_with_preinstall

*保存镜像*
../bin/docker save -o openeuler-20.03-lts-sp2_with_preinstall.tar 044df723ce5d
../bin/docker image rm 044df723ce5d
